Skip to content

Speed up inherited-time check in testRequiredTime - #12

Merged
rob-metalinkage merged 1 commit into
opengeospatial:masterfrom
rob-metalinkage:clean-pr-1793164347.32312
Oct 28, 2026
Merged

rob-metalinkage merged 1 commit into
opengeospatial:masterfrom
rob-metalinkage:clean-pr-1793164347.32312

Conversation

@rob-metalinkage

Copy link
Copy Markdown
Collaborator

The second SPARQL constraint of testRequiredTime (at most one resultTime/phenomenonTime, possibly inherited from the nearest collection) is very slow on large collections.

In the inherited-value branch, ?holder ... ; ?path ?time was matched with ?path unbound and only narrowed by FILTER(?path IN (...)) afterwards. rdflib therefore enumerated every property of the collection, e.g. every geojson:features link, and ran the "nearer collection" FILTER NOT EXISTS test for each row before the filter discarded them.

This change binds ?path first with { BIND(sosa:resultTime AS ?path) } UNION { BIND(sosa:phenomenonTime AS ?path) }. (VALUES would be simpler but is not allowed in SHACL-SPARQL constraints; pyshacl rejects it.) The query semantics are unchanged.

Impact (measured on a 3D-CSDM cadastral survey with 1168 features and 486 observations):

  • per observation: ~4.9 s → ~0.03 s
  • whole execution/shapes.shacl validation of that dataset: >15 min → 23.5 s
  • downstream 3d-csdm-profile-wa build: ~46 min → 9 min, with identical validation results

Testing: local build of this register: 47/47 building blocks pass, and every SHACL/schema test gives the same result as the current CI build, including collection-time-ambiguous-inherited-fail (exercises this branch) and collection-time-nearest-inherited (the nearer-collection exemption).

🤖 Generated with Claude Code

Bind ?path (resultTime/phenomenonTime) before matching the collection's
triples instead of filtering it afterwards. With ?path unbound, rdflib
enumerated every property of the collection (e.g. all geojson:features
links) and ran the "nearer collection" NOT EXISTS test for each row
before the filter removed them: ~5s per observation on a 1168-feature
CSD (40 min for 486 observations), now ~0.03s. VALUES would be simpler
but is not allowed in SHACL-SPARQL constraints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rob-metalinkage
rob-metalinkage merged commit 6fe555a into opengeospatial:master Oct 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant